import matplotlib.pyplot as plt
from typing import List
from .interfaces import SimulationFrame

class Visualizer:
    def __init__(self):
        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111, projection='3d')
        # 初始化图形属性
        
    def update(self, frame: SimulationFrame):
        """更新显示"""
        self.ax.cla()  # 清除上一帧
        
        # 绘制真实轨迹
        for track in frame.true_tracks:
            self.ax.scatter(
                track.position[0],
                track.position[1],
                track.position[2],
                color='blue',
                alpha=0.5
            )
            
        # 绘制测量点
        for meas in frame.measurements:
            self.ax.scatter(
                meas.position[0],
                meas.position[1],
                meas.position[2],
                color='red',
                marker='x'
            )
            
        self.ax.set_xlabel('X (m)')
        self.ax.set_ylabel('Y (m)')
        # self.ax.set_zlabel('Z (m)')
        plt.pause(0.01)  # 短暂停顿实现动画效果